var express = require('express');
var app = express()
var bodyParser = require('body-parser')
app.use('/public', express.static('./public'));
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())
app.engine('html', require('express-art-template'));
app.set('views', 'view')
var showdata = [{
  name: '郭佳佳',
  age: '23',
  sex: 'women',
  status: 'girlfriend'
}, {
  name: '谭明',
  age: '23',
  sex: 'man',
  status: 'boyfriend'
}]
app.get('/index', function (req, res) {
  res.render('index.html', {
    showdata: showdata
  })
})
app.get('/post', function (req, res) {
  res.render('post.html')
})
app.post('/pushtalk', function (req, res) {
  console.log(req.body);
  let newdata = req.body;
  showdata.unshift(newdata);
  res.redirect('/index')
})
/* app.get('/pushtalk', function (req, res) {
  let newdata = req.query;
  showdata.unshift(newdata);
  res.redirect('/index')
  //res.render('post.html')
}) */
app.listen(3000, function () {
  console.log('this Serve is running........');
})